package com.kaoshi.T20;

import java.io.File;

/**
 * @author xiyu
 * @version 1.0
 * @date 2025/4/7 14:51
 * @description
 */
public class Test {
    static int mp3 = 0;
    static String mp3s = "";
    public static void main(String[] args) {
        File dir = new File("d:/softeem/music素材");
        typeCount(dir);
        System.out.println("mp3文件总个数有："+mp3);
        System.out.println("该目录下的mp3文件有："+mp3s);
    }

    public static void typeCount(File dir) {
        File[] files = dir.listFiles();
        for (File file : files) {

            if (file.isDirectory()) {
                typeCount(file);
            }else {
                String fileName = file.getName();
                String type = fileName.substring(fileName.indexOf('.')+1);
                if (type.equals("mp3")){
                    mp3s = mp3s+fileName+" ";
                    mp3++;
                }
            }
        }
    }
}
